import type { PlusColumn } from 'plus-pro-components'

import { ORDERSTATUTOPTIONS } from '../../constant'

export function useForm() {
    const schema: PlusColumn[] = [
        {
            colProps: {
                span: 8,
            },
            label: '状态',
            options: ORDERSTATUTOPTIONS,
            prop: 'orderStatus',
            valueType: 'select',
        },
        {
            colProps: {
                span: 8,
            },
            label: '订单编号',
            prop: 'orderNo',
            valueType: 'copy',
        },
        {
            colProps: {
                span: 8,
            },
            label: '订单名称',
            prop: 'orderName',
            valueType: 'copy',
        },
        {
            colProps: {
                span: 8,
            },
            label: '甲方',
            prop: 'partyA',
            valueType: 'copy',
        },
        {
            colProps: {
                span: 8,
            },
            label: '乙方',
            prop: 'partyB',
            valueType: 'copy',
        },
        {
            colProps: {
                span: 8,
            },
            fieldProps: {
                endPlaceholder: '结束日期',
                startPlaceholder: '开始日期',
                type: 'daterange',
                valueFormat: 'YYYY-MM-DD',
            },
            label: '下单时间',
            prop: 'selectTime',
            valueType: 'date-picker',
        },
        {
            colProps: {
                span: 8,
            },
            label: '合同名称',
            prop: 'agreementName',
            valueType: 'copy',
        },

    ] as const

    const state = {
        agreementName: '',
        orderName: '',
        orderNo: '',
        orderStatus: '',
        partyA: '',
        partyB: '',
        selectTime: '',
    }
    const form = ref({
        ...state,
    })

    function reset() {
        form.value = {
            ...state,
        }
    }

    return { form, reset, schema, state }
}
